/*
 * PageVoidKeyImpl_.h
 *
 *  Created on: Aug 1, 2011
 *      Author: yong
 */

#ifndef PAGEVOIDKEYIMPL__H_
#define PAGEVOIDKEYIMPL__H_
#include<cstddef>
#include<string>
#include "../KeyValue.h"
#include "../Typedef.h"

using namespace std;
namespace distrim
{
/**
 * Page with values only.
 */
template<typename V>
class Page<void, V>
{
public:
	Page(const size_t pageID = 0, void *ptrPageBeg = NULL,
			const string &fileName = "") :
		m_pageID(pageID), m_ptrPageBeg(ptrPageBeg), m_fileName(fileName)
	{
	}
	virtual ~Page()
	{
	}

protected:
	/**
	 * ID of page, read only.
	 */
	size_t m_pageID;
	/**
	 * The beginning pointer of memory page allocated by memory page master,
	 * 	if it is not in memory, then should be NULL.
	 */
	void *m_ptrPageBeg;
	/**
	 *
	 */
	string m_fileName;


public:

	/**
	 * To be overridden by inheritted classes.
	 */
	virtual void ReadFromDisk() = 0;

	/**
	 * To be overridden by inheritted classes.
	 */
	virtual void WriteToDisk() = 0;
	/**
	 *
	 */
	inline void SetFileName(const string &fileName)
	{
		m_fileName = fileName;
	}
	/**
	 *
	 */
	inline const string &GetFileName() const
	{
		return m_fileName;
	}
	/**
	 *
	 */
	inline void SetPageBegin(void *ptrBeg)
	{
		m_ptrPageBeg = ptrBeg;
	}
	/**
	 * Set page id.
	 */
	inline void SetPageID(size_t pageID)
	{
		m_pageID = pageID;
	}
	/**
	 * Get page id.
	 */
	inline size_t GetPageID() const
	{
		return m_pageID;
	}

};

}

#endif /* PAGEVOIDKEYIMPL__H_ */
